

use "$data/survey1_clean.dta", clear

global control male age_* log_inc log_inc_sq highschool college working student democrat republican 


   *** Worries***

loc experiments "z_worry_corona_econ z_worry_perecon"
		   
			   
preserve 

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

global output_coeff ""
global output_se ""
global output_name""

foreach choice in `experiments' {

/* Statistics */

	


 xi:  reg `choice'_update  contagiontreatment highmort `choice' , vce(r)
 
    sigstar contagiontreatment, prec(4)
    estadd loc thisstat3 = "`r(bstar)'": col`colnum'
    estadd loc thisstat4 = "`r(sestar)'": col`colnum'


    estadd loc thisstat6 =  string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'_update  
	estadd loc thisstat7 =  r(N): col`colnum'


 xi:  reg `choice'_update  contagiontreatment highmort `choice' $control, vce(r)
 
    sigstar contagiontreatment, prec(4)
    estadd loc thisstat10 = "`r(bstar)'": col`colnum'
    estadd loc thisstat11 = "`r(sestar)'": col`colnum'

    estadd loc thisstat13 =  string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'_update  
	estadd loc thisstat14 =  r(N): col`colnum'

	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"

	


	} 
	

	

loc rowlabels " "{\bf Panel A: No control variables}"  "\midrule"  "Contagion information" " " " " "\midrule R$^2$" " Number of Observations " "\midrule {\bf Panel B: Including control variables}" "\midrule"  " Contagion information" " " " " "\midrule R$^2$" " Number of Observations " "\bottomrule""


loc rowstats ""

forval i = 1/14 {
    loc rowstats "`rowstats' thisstat`i'"
}

esttab * using "$tables/contagion_cross_rand_check.tex", replace cells(none) booktabs nonotes compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
   mtitle("US Economy" "Pers. Economic Sit."  ) ///
   mgroups("Worry about (standardized)" ,  pattern(1 0  1 0   ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

